  <?php require_once('connections/con_gl.php'); ?>
  <?php
cekAkses($_SESSION[akses],"PJ-7-2");
// -- info order
mysql_select_db($database_con_gl, $con_gl);
$query = "SELECT * from v_kasir_korporate where no_ref = '$_GET[noreferensi]' and unit_id='$_GET[id_unit]'";
$order = mysql_query($query, $con_gl) or die(mysql_error());
$row_order = mysql_fetch_assoc($order);
$totalRows_order = mysql_num_rows($order);

$query_listbayar = "SELECT * from v_kasir_listbayar where no_ref = '$_GET[noreferensi]' and id_unit='$_GET[id_unit]'";
$order_listbayar  = mysql_query($query_listbayar, $con_gl) or die(mysql_error());
$row_order_listbayar = mysql_fetch_assoc($order_listbayar);
$totalRows_order_listbayar = mysql_num_rows($order_listbayar);

     
?>
<link href="ccss/ui.datepicker.css" type="text/css" rel="stylesheet" />
<style>
#cusinfo tr td {
	font-size:10px;	
}
</style>
<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript">
<!--
$(function()
      {
        $('.calendar').datepicker({
            appendText : "",
            dateFormat : ''
          });
      });
	  
</script>
<script type="text/javascript" src="js/ajax_data.js"></script>
<script type="text/javascript">
$(document).ready(function() {

	$().ajaxStart(function() {
		$('#loading').show();
		$('#result').hide();
	}).ajaxStop(function() {
		$('#loading').hide();
		$('#result').fadeIn('slow');
	});

	$('#bayar').submit(function() {
		$.ajax({
			type: 'POST',
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(data) {
				$('#result').html(data);
			}
		})
		return false;
	});
  $('#result').click(function(){
  $(this).hide();
  });
})
</script>
<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading...."/></div>
<div id="result" style="display:none;"></div>
<div id="divDetail">
  <table width="100%" border="0" cellspacing="0" cellpadding="4" class="datatable" id="cusinfo">
    <tr>
      <th colspan="4" align="left"  style="background:#FF6600" ><h1 style="color:#FFFFFF; text-shadow:none">PEMBAYARAN CUSTOMER CORPORATE</h1></th>
    </tr>
    <tr>
      <th colspan="4" align="center"  style="background:#FFFFFF">&nbsp;</th>
    </tr>
    <tr>
      <th colspan="4" align="center">INFORMASI SEWA KENDARAAN</th>
    </tr>
    <tr>
      <td align="right" valign="top" style="background:#FFF;"><div align="left">TRANSAKSI</div></td>
      <td width="33%" valign="top" style="background:#FFF;">&nbsp;</td>
      <td valign="top" style="background:#FFF;">INFO LAYANAN</td>
      <td width="31%" valign="top" style="background:#FFF;">&nbsp;</td>
    </tr>
    <tr>
      <td align="right" valign="top" style="background:#FFF;">No Invoice :</td>
      <td valign="top" style="background:#FFF;"><?php echo $_GET[noreferensi];?></td>
      <td width="16%" align="right" valign="top" style="background:#FFF;">No Kontrak:</td>
      <td valign="top" style="background:#FFF;"><?php echo $row_order['kontrak']; ?></td>
    </tr>
    <tr>
      <td width="20%" align="right" valign="top" style="background:#FFF;">Customer :</td>
      <td valign="top" style="background:#FFF;"><?php echo $row_order['nama']; ?></td>
      <td align="right" valign="top" style="background:#FFF;">Periode Kontrak :</td>
      <td valign="top" style="background:#FFF;"><?php echo $row_order['mulai'];?> s/d <?php echo $row_order['sampai'];?></td>
    </tr>
    <tr>
      <td align="right" valign="top" style="background:#FFF;">Kendaraan :</td>
      <td valign="top" style="background:#FFF;"><?php echo $row_order['kendaraan']; ?></td>
      <td align="right" valign="top" style="background:#FFF;">Durasi Pembayaran :</td>
      <td valign="top" style="background:#FFF;"><?php echo $row_order['durasi']; ?> bulan</td>
    </tr>
  </table>
</div>
<h3>Daftar Detail Pembayaran</h3>

<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable"> 
<tr>
    <th width="78"><strong>Tanggal</strong></th>
    <th width="78"><strong>No Order</strong></th>
	<th width="78">Jenis Bayar </th>
   	<th width="78">Metode Bayar </th>
    <th width="78">Kasir</th> 
    <th width="78" align="center"><strong>Nominal</strong></th>

  </tr>
  	  <?php if($totalRows_order_listbayar > 0) { ?>
  <?php do { ?>
    <tr valign="top" bgcolor="#FFFFFF">
      <td><?php echo $row_order_listbayar['tgl_bayar']; ?></td>
      <td><?php echo $row_order_listbayar['no_ref']; ?></td>
      <td><?php echo $row_order_listbayar['jns_pemb']; ?></td>
      <td><?php echo $row_order_listbayar['tipe_pemb']; ?></td>            
      <td><?php echo $row_order_listbayar['hold_status']; ?></td>
     <td><?php echo number_format($row_order_listbayar['totalbayar'],0,',','.').",-"; ?></td>
     
    </tr>
    <?php } while ($row_order_listbayar = mysql_fetch_assoc($order_listbayar)); ?>

   <?php }else{ ?>
  <tr bgcolor="#FFFFFF">
    <td colspan="5">Data tidak ada !!! </td>
  </tr>
  <?php } ?>
</table>
<br>
<?php

mysql_select_db($database_con_gl, $con_gl);

$query_cr_tipebayar = "SELECT id, tipe_pemb FROM gl_tipepembayaran";

$cr_tipebayar = mysql_query($query_cr_tipebayar, $con_gl) or die(mysql_error());

$row_cr_tipebayar = mysql_fetch_assoc($cr_tipebayar);

$totalRows_cr_gud = mysql_num_rows($cr_tipebayar);


$query_cr_jenisbayar = "SELECT id, jns_pemb FROM gl_jenispembayaran where id NOT IN (select jns_pemb from gl_pembayaran where jns_pemb = 1 and id_unit = '$row_order[unit_id]')";

$cr_jenisbayar = mysql_query($query_cr_jenisbayar, $con_gl) or die(mysql_error());

$row_cr_jenisbayar = mysql_fetch_assoc($cr_jenisbayar);

$totalRows_cr_jenisbayar = mysql_num_rows($cr_jenisbayar);

?>

<form action="proses/korporatebayar.php?act=bayar" method="POST" name="bayar" id="bayar" >
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
    <tr>
      <th colspan="4">Pembayaran</th>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Metode Pembayaran :</td>
      <td valign="top" bgcolor="#FFFFFF"><select name="cr_tipebayar">
        <?php

do {  

?>
        <option value="<?php echo $row_cr_tipebayar['id']?>"><?php echo $row_cr_tipebayar['tipe_pemb']?></option>
        <?php

} while ($row_cr_tipebayar = mysql_fetch_assoc($cr_tipebayar));

  $rows = mysql_num_rows($cr_tipebayar);

  if($rows > 0) {

      mysql_data_seek($cr_tipebayar, 0);

	  $row_cr_tipebayar = mysql_fetch_assoc($cr_tipebayar);

  }

?>
      </select>
      <input name="no_ref" type="hidden" id="no_ref" value="<?php echo $_GET[noreferensi];?>" size="20" maxlength="10" style="text-align:right;" /></td>
      <td valign="top" bgcolor="#FFFFFF">Total Sewa </td>
      <td valign="top" bgcolor="#FFFFFF"><input name="totalsewa" type="text" id="totalsewa"  value="<?php echo $row_order['total']; ?>" size="20" maxlength="10" style="text-align:right;" />
      <input name="unit_id" type="hidden" id="unit_id"  value="<?php echo $row_order['unit_id']; ?>" size="20" maxlength="10" style="text-align:right;" /></td>
    </tr>
    <tr>
      <td align="right" valign="top" bgcolor="#FFFFFF">Jenis  Pembayaran</td>
      <td valign="top" bgcolor="#FFFFFF"><select name="cr_jenisbayar">
        <?php

do {  

?>
        <option value="<?php echo $row_cr_jenisbayar['id']?>"><?php echo $row_cr_jenisbayar['jns_pemb']?></option>
        <?php

} while ($row_cr_jenisbayar = mysql_fetch_assoc($cr_jenisbayar));

  $rows = mysql_num_rows($cr_jenisbayar);

  if($rows > 0) {

      mysql_data_seek($cr_jenisbayar, 0);

	  $row_cr_jenisbayar = mysql_fetch_assoc($cr_jenisbayar);

  }

?>
      </select></td>
      <td valign="top" bgcolor="#FFFFFF">Pajak   </td>
      <td valign="top" bgcolor="#FFFFFF"><input name="totalsewa2" type="text" id="totalsewa2"  value="<?php echo $row_order['pajak']; ?>" size="20" maxlength="10" style="text-align:right;" /></td>
    </tr>
    <tr valign="top">
      <td align="right" valign="top" bgcolor="#FFFFFF">Pembayaran Rp :</td>
      <td valign="top" class="datatable"><input name="pembayaran" type="text" id="pembayaran" value="0" size="20" maxlength="10" style="text-align:right;" /></td>
      <td valign="top" class="datatable">Pph 23</td>
      <td valign="top" class="datatable"><!-- Added by suwondo -->
        <input name="totalsewa3" type="text" id="totalsewa3"  value="<?php echo $row_order['pph']; ?>" size="20" maxlength="10" style="text-align:right;" /></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Keterangan Transaksi</td>
      <td bgcolor="#FFFFFF"><textarea name="keterangan" cols="35" rows="2" id="keterangan"></textarea></td>
      <td bgcolor="#FFFFFF">Kekurangan </td>
      <td bgcolor="#FFFFFF"><?php
			
		    $kekurangan = ($row_order['sisakekurangan'] == "" ? $row_order['total'] : $row_order['sisakekurangan']);
		  ?>
          <input name="kekurangan" type="text" id="kekurangan" readonly="readonly" value="<?php echo  $kekurangan; ?>" size="20" maxlength="10" style="text-align:right;" /></td>
    </tr>
    <tr valign="top">
      <td width="8%" align="right" bgcolor="#FFFFFF"><input name="Save" type="submit" id="Save" value="Bayar" /></td>
      <td width="22%" bgcolor="#FFFFFF"><input name="Cancel2" type="button" id="Cancel2" value="Batal" onclick="window.close();"/></td>
      <td width="8%" bgcolor="#FFFFFF">&nbsp;</td>
      <td width="62%" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
       <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  </table>
</form>

